# -*- coding: utf-8 -*-
# @Time: 2025/4/23 17:31
# @Author: foxhuty
# @File: pytorch_notes_2.py

import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F

# 常用的张量
a = torch.Tensor([[1, 2, 3], [4, 5, 6]])
print(a)
print(a.shape)
print(a.type())
b = torch.Tensor(2, 3)
print(b)
print(b.shape)
print(b.type())
c = torch.ones(2, 3)
print(c)
print(c.shape)
print(c.type())
d = torch.zeros(2, 3)
print(d)
print(d.shape)
print(d.type())
e = torch.eye(9, 8)
print(e)
print(e.shape)
print(e.type())
# 特殊的张量
f = torch.zeros_like(c)
print(f)
print(f.shape)
print(f.type())
g = torch.ones_like(c)
print(g)
print(g.shape)
# 随机的张量
h = torch.rand(3, 4)
print(h)
print(h.shape)
print(h.type())
# 正态分布的张量
i = torch.normal(mean=torch.rand(5), std=torch.rand(5))
print(i)
print(i.shape)
print(i.type())
# 序列分布的张量
j = torch.arange(0, 20, 2)
print(j)
print(j.shape)
print(j.type())
# 等间隔的张量
k = torch.linspace(0, 10, 5)
print(k)
print(k.shape)
print(k.type())
# 随机顺序的张量
l = torch.randperm(10)
print(l)
print(l.shape)

